#ifndef __RECTANGLE_H__
#define __RECTANGLE_H__

#include <vector>
#include <QtCore/QList>
#include <QtGui/QGraphicsRectItem>

namespace verema {

class Rectangle
{
public:
    /**
     * \brief constructor
     */
    Rectangle(){};

    /**
     * \brief destructor
     */
    ~Rectangle(){};

    /**
     * \brief returns the item belonging to the given id
     * \param id the id from database
     * \return 0 if given id was not found
     */
    QGraphicsRectItem* at(int id);

    /**
     * \brief returns the id belonging to the given item
     * \param *gri pointer to the item
     * \return -1 if given item was not found
     */
    int id(QGraphicsRectItem *gri);

    /**
     * \brief function for getting the state of an item
     */
    bool used(int id);

    /**
     * \brief function for setting the state of the item related to the given id
     */
    void used(int id, bool state);

    /**
     * \brief function for setting the id of a specific Item
     */
    void id(QGraphicsRectItem *gri, int id);

    /**
     * \brief adds an item
     * \param *gri parameter containing a pointer to the QGraphicsRectItem
     * \param id the id of the item from database
     */
    void push_back(QGraphicsRectItem *gri, int id, bool used);

    /**
     * \brief returns an iterator to the first element of the item vector
     */
    QList<QGraphicsRectItem *>::Iterator begin();

    /**
     * \brief returns an iterator to the last element of the item vector
     */
    QList<QGraphicsRectItem *>::Iterator end();

    /**
     * \brief removes the given id and the belonging item
     * \param id the id taken from database
     */
    void remove(int id);

    /**
     * \brief removes the given item and the belonging id
     */
    void remove(QGraphicsRectItem *gri);

    /**
     * \brief returns the count of items/ids
     */
    int count();

    /**
     * \brief clears the whole item vector and the ids
     */
    void clear();

private:
    std::vector<int> id_vector;
    std::vector<bool> used_vector;
    QList<QGraphicsRectItem*> rect_vector;
};

}// namespace verema

#endif //__RECTANGLE_H__
